<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('字典值修改')"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-block">
                        <input type="text" th:value="${dataInfo.id}" name="id" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">字典键值</label>
                    <div class="layui-input-block">
                        <input type="text" th:value="${dataInfo.dataKey}" name="dataKey" lay-verify="title"
                               autocomplete="off" placeholder="请输入字典键值" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">字典显示值</label>
                    <div class="layui-input-block">
                        <input type="text" th:value="${dataInfo.dataLabel}" name="dataLabel" lay-verify="title"
                               autocomplete="off" placeholder="请输入字典显示值" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">字典代码值</label>
                    <div class="layui-input-block">
                        <input type="text" th:value="${dataInfo.dataValue}" name="dataValue" lay-verify="title"
                               autocomplete="off" placeholder="请输入字典代码值" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">字典类型</label>
                    <div class="layui-hide">
                        <input type="text" th:value="${dataInfo.typeCode}" name="typeCode" class="layui-input">
                    </div>
                    <div class="layui-input-block">
                        <input type="text" th:value="${dataInfo.typeName}" readonly name="typeName"
                               lay-verify="title" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" th:checked="${dataInfo.enable eq 1}" name="enable" value="1"
                               title="启用">
                        <input type="radio" th:checked="${dataInfo.enable eq 0}" name="enable" value="0"
                               title="禁用">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入描述" th:text="${dataInfo.remark}" name="remark"
                                  class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="dict-data-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(dict-data-save)', function (data) {
            $.ajax({
                url: '/standard/dict/data/save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("dict-data-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>